package com.dou361.ijkplayer.widget;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.widget.EditText;
import android.widget.RelativeLayout;

import com.dou361.ijkplayer.R;
import com.dou361.ijkplayer.basepopup.BasePopupWindow;
import com.dou361.ijkplayer.utils.KeybordS;

/**
 * Created by carolina on 2017/7/13.
 */

public class SlideBottomEdit extends BasePopupWindow {
    private View popupView;
    private EditText editText;
    private Activity mActivity;
    private RelativeLayout clickDismiss;

    public SlideBottomEdit(Activity context) {
        super(context);
        this.mActivity=context;
        bindEvent();
    }
    //初始化控件
    private void bindEvent() {
        if(popupView!=null){
            editText = popupView.findViewById(R.id.et_simple);
            clickDismiss = popupView.findViewById(R.id.click_to_dismiss);
        }
    }

    @Override
    protected Animation initShowAnimation() {
        return getTranslateAnimation(250 * 2, 0, 300);
    }

    @Override
    public View getClickToDismissView() {
        setOnDismissListener(new OnDismissListener() {
            @Override
            public void onDismiss() {
                String system = MobileSys.getSystem();
                if(MobileSys.SYS_FLYME.equals(system)){
                    KeybordS.HideKeyboard(popupView);
                }else {
                    KeybordS.openKeybord((EditText) popupView.findViewById(R.id.et_simple),mActivity);
                }
                //popupView.findViewById(R.id.et_simple).clearFocus();



            }
        });
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View onCreatePopupView() {
        popupView = LayoutInflater.from(getContext()).inflate(R.layout.simple_edit, null);
        return popupView;
    }

    @Override
    public View initAnimaView() {
        return popupView.findViewById(R.id.edit_rela);
    }


    @Override
    public void showPopupWindow() {
        super.showPopupWindow();

    }
    //获取点击取消的相对布局
    public RelativeLayout getClickDismiss(){
        return clickDismiss;
    }
    //获取输入框
    public EditText getEditText(){
        return editText;
    }




}


